﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using Nova_DAL;
using System.Data.Common;
using Nova_Common;
using System.Text;
using System.Data;
using System.IO;

public partial class Views_StorageList : System.Web.UI.Page
{
    DbHelper access = new DbHelper();
    DbCommand cmd = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGrid();
        }
    }
    protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

    }
    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[7].Text == "0")
            {
                e.Row.Cells[7].Text = "箱";
            }
            else if (e.Row.Cells[7].Text == "1")
            {
                e.Row.Cells[7].Text = "袋";
            }
            else
            {
                e.Row.Cells[7].Text = "桶";
            }
        }
    }

    private void BindGrid()
    {
        string strSQL = @"SELECT TBS.Mat_Num,TBS.Sec_Mat_ID,TBS.ContainerID,TBT.Relations_ID,TBT.Tray_ID, 
                    TBI.Mat_Code, TBI.S02,TBI.S03,TBI.S04,TBI.S05,TBS.CDT,
                    TBI.S06,TBI.S07,TBI.S08,TBI.S09,TBS.MAT_Num*ISNULL(CAST(TBI.S09 AS int),0) as ZS10,TBI.S11,TBC.CustomName,
                    TBI.S12,TBI.S13,TBI.S14,TBI.S15,TBI.S16,TBM.Mat_Name,TRP.Pos_ID  FROM TRelations TRP 
                    LEFT JOIN TBase_TrayPos TBT ON TRP.Tray_ID = TBT.Tray_ID 
                    LEFT JOIN TRel_TrayPosContainer TRT ON TRT.Relations_ID = TBT.Relations_ID 
                    LEFT JOIN TBase_Storage TBS ON TBS.ContainerID = TRT.ContainerID
                    LEFT JOIN TBase_Interface TBI ON TBI.Sec_Mat_ID = TBS.Sec_Mat_ID
                    LEFT JOIN TBase_Material TBM on TBM.Mat_Code = TBI.Mat_Code
                    LEFT JOIN TBCustom TBC ON TBC.CustomNo = TBI.S13  
                    where 1=1 AND TRP.Pos_ID= " + Request.QueryString["PosID"];

        cmd = access.GetSqlStringCommond(strSQL);
        gv.DataSource = access.ExecuteDataSet(cmd);
        gv.DataBind();

    }
}
